package com.supercube.wechat.controller;

import com.supercube.wechat.domain.Signature;
import com.supercube.wechat.utils.CheckUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信公众号相关控制器
 *
 * @author djzhao
 * @date 20/08/29 22:36
 * @email djzhao627@gmail.com
 */
@RestController
@RequestMapping("/publicAccount")
public class PublicAccountController {

    @GetMapping("/")
    public String publicAccount(String signature, String timestamp, String nonce, String echostr) {
        Signature sg = new Signature(signature, timestamp, nonce, echostr);
        if (CheckUtil.checkSignature(sg)) {
            return sg.getEchostr();
        } else {
            return "";
        }
    }

}
